import React from 'react';
import {Link, useLocation} from "react-router-dom";
import {SecurityUserType} from "type/SecurityUser";
import {Card, Descriptions} from "antd";
import {getTag} from "util/ColumnsUtil";

const UserDetailsComponent = () => {
    const user: SecurityUserType = useLocation().state ;
    return (
        <Card title={"用户详细信息"} extra={<Link to={".."}>用户列表</Link> }>
           <Descriptions
               bordered={true}
               column={2}
               items={[
                   {
                       key: 'username',
                       label: '用户名',
                       children: user.username
                   },
                   {
                       key: 'id',
                       label: '用户编号',
                       children: user.id
                   },
                   {
                       key: 'key',
                       label: '唯一表示',
                       children: user.key
                   },
                   {
                       key: 'password',
                       label: '用户密码',
                       children: user.password
                   },
                   {
                       key: 'version',
                       label: '数据版本',
                       children: user.version
                   },
                   {
                       key: 'identity',
                       label: '用户身份',
                       children: user.identity
                   },
                   {
                       key: 'createTime',
                       label: '创建时间',
                       children: user.createTime.toString()
                   },
                   {
                       key: 'updateTime',
                       label: '更新时间',
                       children: user.updateTime.toString()
                   },
                   {
                       key: 'age',
                       label: '用户姓名',
                       children: user.age
                   },
                   {
                       key: 'gender',
                       label: '用户性别',
                       children: user.gender ? "男" : "女"
                   },
                   {
                       key: 'delete',
                       label: '逻辑删除',
                       children: getTag(!user.delete,"未删除","已删除")
                   },
                   {
                       key: 'enabled',
                       label: '用户启用',
                       children: getTag(user.enabled,"未启用","已启用")
                   },
                   {
                       key: 'accountNonLocked',
                       label: '用户锁定',
                       children: getTag(user.accountNonLocked,"未锁定","已锁定")
                   },
                   {
                       key: 'accountNonExpired',
                       label: '用户过期',
                       children: getTag(user.accountNonExpired,"未过期","已过期")
                   },
                   {
                       key: 'credentialsNonExpired',
                       label: '密码过期',
                       children: getTag(user.credentialsNonExpired,"未过期","已过期")
                   },
                   {
                          key: 'remark',
                          label: '备注信息',
                          children: user.remark
                   }
               ]}
           />
        </Card>
    );
};

export default UserDetailsComponent;